import { defineStore } from 'pinia';

export const useUserStore = defineStore('user', {
  state: () => ({
    isLoggedIn: false,
    userInfo: null
  }),
  
  actions: {
    login(userData) {
      this.isLoggedIn = true;
      this.userInfo = userData;
    },
    
    logout() {
      this.isLoggedIn = false;
      this.userInfo = null;
    },
    
    checkLoginStatus() {
      // 这里可以添加检查登录状态的逻辑
      // 例如检查 localStorage 或发送请求到后端验证 token
      const token = localStorage.getItem('token');
      this.isLoggedIn = !!token;
    }
  }
}); 